<%@ page language="java" import="java.util.*,com.ruohi.util.common.*,com.ruohi.util.dbutil.*" pageEncoding="UTF-8"%><%
	String tableName = "service_common_log";
	String fileds = "id,add_user,add_date,add_ip,uuid,channel_name,content,type,log_level,referer";
	String whereStr = " ";
	Map adminInfo = (Map)session.getAttribute("adminInfo");
	if(adminInfo.get("usern").equals("admin")){
		whereStr = "";
	}
	String orderByStr = " add_date desc , id desc ";
	DBHelper dbHelper = DBHelper.getInstance();
	LinkedHashMap typeMap = (LinkedHashMap)CommonApplication.getEnumChildren("105",application);
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title><%=Env.getInstance().getProperty("project_name") %></title>
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
	<link href="/backend/style/style.css" rel="stylesheet" type="text/css" />
	<script src="/plugin/jquery/jquery.min.js" type="text/javascript"></script>
  </head>
  <body>
  	<div class="searchForm">
  		<div class="searchCondition">
  			<div class="searchList">
		  		<div class="searchLeft">操作类型</div>
		  		<div class="searchRight">
		  			<select name="type" id="type" class="jr_select">
		  				<option value="">--请选择操作类型--</option>
		  				<%=CommonForm.createSelect(typeMap,"") %>
		  			</select>
		  		</div>
	  		</div>
	  		<div class="searchList">
				<div class="searchLeft">操<span class="span3"></span>作<span class="span3"></span>者</div>
		  		<div class="searchRight">
		  			<input type="text" name="add_user" class="jr_text" id="add_user" />
		  		</div>
	  		</div>
	  		<div class="searchList">
				<div class="searchLeft">操作日期</div>
		  		<div class="searchRight">
		  			<input type="text" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" name="add_date" id="add_date" />
		  		</div>
		  	</div>
	  		<div class="searchList">
		  		<div class="searchLeft">内容包含</div>
		  		<div class="searchRight">
		  			<input type="text" name="content" id="content" class="jr_text" />
		  		</div>
		  	</div>
		  	<div class="searchList">
		  		<div class="searchLeft">不<span class="span3"></span>包<span class="span3"></span>含</div>
		  		<div class="searchRight">
		  			<input type="text" name="no_content" id="no_content" class="jr_text" />
		  		</div>
	  		</div>
  		</div>
  		<div class="searchBtn">
  			<input type="button" class="btn" onclick="doSearch();" value="查询" style="margin-right: 5px;" />
  			<input type="button" class="btn" onclick="doClearForm();" value="重置" />
  		</div>
  	</div>
  	<div style="clear: left;"></div>
	<div class="l-loading" style="display: block" id="pageloading"></div> 
	<div id="maingrid" style="margin: 0; padding: 0"></div>
	<div style="display: none;"></div>
  </body>
</html>
<script src="/plugin/ui/ligerUI/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="/plugin/date/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="/backend/scripts/common.js" type="text/javascript"></script>
<script type="text/javascript">
	var grid;
	var tableName = '<%=tableName %>';
	var fields = '<%=fileds %>';
	var channelUUID = '';
	var whereStr = '<%=whereStr %>';
	var orderBy = '<%=orderByStr %>';
	var columnsArr = [];
	var url = '';
	var conditionStr = '';
	var main = '';
	var params = [];
	jQuery(function() {
		grid = new Dev21sunGrid({
			checkbox : false
		});
		jQuery("#pageloading").hide();
	});
	
	//列数组
	columnsArr =  [
		{ display : 'ID', name : 'id', align : 'left' , type : 'string' , width : 100 } ,
		{ display : '操作者', name : 'add_user', align : 'left' , type : 'string' , width : 100 } ,
		{ display : '添加日期', name : 'add_date', align : 'center' , type : 'string' , width : 200 } ,
		{ display : '操作者IP', name : 'add_ip', align : 'center' , type : 'string' , width : 100 } ,
		{ display : '来源地址', name : 'referer', align : 'center' , type : 'string' , width : 100 } ,
		{ display : '频道名称', name : 'channel_name', align : 'left' , type : 'string' , width : 100 } ,
		{ display : '操作内容', name : 'content', align : 'left' , type : 'string' , width : 500 , render : function(row){
				if(row.type=='105002'){
					return "<a class='link' href='javascript:void(0);' onclick='addAndEdit("+row.__index+");'>邮件内容请点击查看</a>";
				}
				return row.content;
			}
		} ,
		{ display : '操作类型', name : 'type', align : 'center' , type : 'string' , width : 100 , render : function(row){
				return getEnum(row.type);
			}
		} ,
		{ display : '日志级别', name : 'log_level', align : 'left' , type : 'string' , width : 100 , render : function(row){
				return getEnum(row.log_level);
			}
		} 
	];
	
	/*列表页条件查询*/
	function doSearch(){
		params = [];
		conditionStr = "";
		var type = jQuery("#type").val();
		if(''!=jQuery.trim(type)){
			conditionStr += " and type = '"+type+"' ";
		}
		var add_user = jQuery("#add_user").val();
		if(''!=jQuery.trim(add_user)){
			conditionStr += " and add_user like '%"+add_user+"%' ";
		}
		var content = jQuery("#content").val();
		if(''!=jQuery.trim(content)){
			conditionStr += " and content like '%"+content+"%' ";
		}
		var no_content = jQuery("#no_content").val();
		if(''!=jQuery.trim(no_content)){
			conditionStr += " and content not like '%"+no_content+"%' ";
		}
		var add_date = jQuery("#add_date").val();
		if(''!=jQuery.trim(add_date)){
			conditionStr += " and Datename(year,add_date)+'-'+Datename(month,add_date)+'-'+Datename(day,add_date) = '"+add_date+"' ";
		}
		params.push({'name':'tableName','value':tableName});
		params.push({'name':'fileds','value':fields});
		params.push({'name':'whereStr','value':conditionStr});
		params.push({'name':'orderBy','value':orderBy});
		grid.options.parms=params;
		grid.loadData();
	}
	
	function addAndEdit(index){
    	if(undefined==index){//如果是增加
			toolbarAdd({
				width:800,
				height:480,
				title:"日志增加"
			});
    	}else{//如果是修改
	    	var row = grid.getRow(index);
	    	toolbarAdd({
		    	width:800,
		    	height:480,
		    	title:"查看日志",
		    	folderName : "common_log",
		    	fileName : "common_log"
	    	},row.uuid);
    	}
    }
</script>